#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=4e5+6;
int k,m,n,Q;
char S[Maxn];
struct ques{
    int l,r,x;
}q[Maxn];

int main(){
    freopen("copy.in","r",stdin);
    freopen("copy.out","w",stdout);
    scanf("%d%d",&k,&m);
    scanf("%s",S+1);n=strlen(S+1);
    scanf("%d",&Q);
    for(int i=1;i<=Q;i++){
        int l,r,x;
        scanf("%d%d%d",&l,&r,&x);
        q[i]=(ques){l,r,x};
    }
    for(int i=1;i<=k;i++){
        // 第 i 个字母，不断撤销操作
        int now=i;
        for(int j=Q;j;j--){
            if(q[j].x<now){
                if(q[j].r-q[j].l+q[j].x>=now){
                    now=q[j].l+now-q[j].x;
                }
                else{
                    now-=(q[j].r-q[j].l);
                }
            }
        }
        printf("%c",S[now]);
    }

    return 0;
}
/*
2 18
copypaste
4
3 6 8
1 5 2
4 12 1
17 18 0
*/